package com.ylx.controller;

import com.ylx.model.common.dtos.ResponseResult;
import com.ylx.model.goods.dtos.GoodsPageReqDto;
import com.ylx.model.goods.pojo.PxxGoods;
import com.ylx.model.img.pojo.PxxImg;
import com.ylx.service.PxxImgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "ImgController-轮播图功能")
@RestController
@RequestMapping("/api/img")
@Slf4j
public class ImgController {
    @Resource
    PxxImgService imgService;


    @GetMapping("/list")
    @ApiOperation("轮播图查询")
    public ResponseResult list(){
        return ResponseResult.okResult(imgService.list());
    }
    @PostMapping("add")
    @ApiOperation("新增轮播图")
    public ResponseResult add(@RequestBody PxxImg pxxImg){
        imgService.save(pxxImg);
        return ResponseResult.okResult("添加成功");
    }
    @PostMapping("update")
    @ApiOperation("修改轮播图")
    public ResponseResult update(@RequestBody PxxImg pxxImg){
        imgService.updateById(pxxImg);
        return ResponseResult.okResult("修改成功");
    }
    @DeleteMapping("del")
    @ApiOperation("删除轮播图")
    public ResponseResult del(@PathVariable("id") int id){
        imgService.removeById(id);
        return ResponseResult.okResult("删除成功");
    }
}
